import axios from 'axios'

export const IncomeContractService = class IncomeContractService {
    static incomeContractService = null
    requestUrl = 'http://localhost/incomeContract'

    static getInstance(){
        if(this.incomeContractService == null){
            this.incomeContractService = new IncomeContractService()
        }
        return this.incomeContractService
    }

    // 获取最大的id
    getMaxId(){
        return axios.get(`${this.requestUrl}/getMaxId`)
    }

    // 保存的方法
    save(incomeForm, incomeDetails){
        const params = { incomeForm, incomeDetails }
        return axios.post(this.requestUrl, params)
    }
    
    // 获取所有的数据
    getIncomeContractData(params){
        return axios.get(this.requestUrl, {params})
    }
    // 用id获取单个数据
    selectOne(params){
        return axios.get(`${this.requestUrl}/${params}`)
    }
    // 用pid获取单个数据
    selectByPid(params){
        return axios.get(`${this.requestUrl}/${params}/byPid`)
    }
    // 查询收入合同明细
    selectInfo(params){
        return axios.get(`${this.requestUrl}/info`, {params})
    }
    // 查询收入合同报表
    selectReport(params){
        return axios.get(`${this.requestUrl}/report`, {params})
    }
}